package com.wyd.qxglht.dao;

import java.util.List;

import javax.transaction.Transactional;

import com.wyd.qxglht.model.Roles;
import com.wyd.qxglht.model.UsersRoles;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface IRolesDao extends JpaRepository<Roles, String>, JpaSpecificationExecutor<Roles> {



    //修改角色
    @Transactional
    @Modifying
    @Query("update Roles r set r.name=:name where r.id=:id")
    int editRole(String id,String name);

    //删除角色
 @Transactional
 @Modifying
 @Query("delete Roles r  where r.id=:id")
 int delRole(String id);


//获取指定用户的角色
    
@Query("select u from UsersRoles u where u.userId = :userId")
List<UsersRoles> getRoles(String userId);


}